/// Copyright (c) 2004-2007, Needlworks / Tatter Network Foundation
/// All rights reserved. Licensed under the GPL.
/// See the GNU General Public License for more details. (/doc/LICENSE, /doc/COPYRIGHT)

try {
	if (i18n=="undefined") var i18n = "ko";
} catch(e) {
	var i18n = "ko";
}
switch (i18n) {
	case "zh-TW":
		var commonString_delete = "刪除";
		var commonString_cancel = "取消";
		var commonString_close = "關閉";
		var commonString_saving = "正在儲存中。";
		var commonString_success = "儲存成功。";
		var commonString_error = "無法儲存。";
		var commonString_cartError = "無法使用所選取的項目。";
		var commonString_remove = "移除所選取的項目。";
	break;
	case "zh-CN":
		var commonString_delete = "删除";
		var commonString_cancel = "取消";
		var commonString_close = "关闭";
		var commonString_saving = "正在储存中。";
		var commonString_success = "储存成功。";
		var commonString_error = "无法储存。";
		var commonString_cartError = "无法使用所选取的项目。";
		var commonString_remove = "移除所选取的项目。";
	break;
	case "en":
		var commonString_delete = "Del";
		var commonString_cancel = "Cancel";
		var commonString_close = "Close";
		var commonString_saving = "Saving...";
		var commonString_success = "Saving success.";
		var commonString_error = "Saving error.";
		var commonString_cartError = "Cannot use the selected item.";
		var commonString_remove = "Remove the selected items.";
	break;
	case "ko":
	default:
		var commonString_delete = "삭제";
		var commonString_cancel = "취소";
		var commonString_close = "닫기";
		var commonString_saving = "저장하고 있습니다.";
		var commonString_success = "제품을 잘 저장했습니다.";
		var commonString_error = "저장하지 못했습니다.";
		var commonString_cartError = "장바구니를 불러오지 못했습니다.";
		var commonString_remove = "장바구니 제품을 모두 삭제했습니다.";
}


djConfig.parseWidgets = false;

dojo.require("dojo.dnd.HtmlDragAndDrop");
dojo.require("dojo.widget.Parse");
dojo.require("dojo.widget.Dialog");	

var globalChker = true;
var globalNewNodeCounter = 0;
var dlg;

dojo.widget.defineWidget( "dojo.widget.popupWindow", dojo.widget.Dialog,
	{
		templatePath: "",
		loadContents: function() {
			this.containerNode = this.domNode;
			return;
		},
		setContent: function(/*String*/ data){
			this.domNode.innerHTML = data;
		},
		placeModalDialog: function() {
			var scroll_offset = dojo.html.getScroll().offset;
			var viewport_size = dojo.html.getViewport();
			
			// find the size of the dialog
			var mb = dojo.html.getMarginBox(this.containerNode);
			if (mb.width<200) mb.width = 200;
			if (mb.height<200) mb.height = 200;
			
			var x = scroll_offset.x + (viewport_size.width - mb.width)/2;
			var y = scroll_offset.y + (viewport_size.height - mb.height)/2;

			with(this.domNode.style){
				left = x + "px";
				top = y + "px";
			}
		}
	}
);

function photoNmediaSearchPop(){
	var requestURL = blogURL + "/plugin/mediaSearchView/";
	var request = new HTTPRequest("GET", requestURL);
	request.onSuccess = function () {
		if (dlg != null) {
			dlg.setContent(this._request.responseText);
			dlg.show();
		}
	}
	request.onError = function () {
		globalChker = false;
	}
	request.onVerify = function () {
		return true;
	}
	request.send();
}

function mediaSelectedTab(selectStr, unselectStr){
	var selectedLogoObj = document.getElementById("media"+selectStr+"Logo");
	var unSelectedLogoObj = document.getElementById("media"+unselectStr+"Logo");
	var mediaSearchFrameObj = document.getElementById("mediaSearchFrame");

	if (selectedLogoObj.className != "media"+selectStr+"LogoSelected") {
		selectedLogoObj.className = "media"+selectStr+"LogoSelected";
		mediaSearchFrameObj.src = blogURL + "/plugin/"+selectStr+"SearchView/";
	}
	unSelectedLogoObj.className = "media"+unselectStr+"LogoUnselected";
}
